home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 2.8 KB | 95 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1993 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Programmer: Kent Sandvik
- Date: 1/2/93
- Revision comments are at the end of this file.
- ---
- TMemory is a simple object checks heap and stack values, as well as changes them.
- TMemoryClass.h contains the TMemory class definitions.
- _________________________________________________________________________________________________________ */
-
- // Declare label for this header file
- #ifndef _MEMORYCLASS_
- #define _MEMORYCLASS_
-
- #ifndef _DTSCPLUSLIBRARY_
- #include "DTSCPlusLibrary.h"
- #endif
-
- // TOOLBOX INCLUDES
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- // GLOBAL DEFINITIONS
- const OSType kStackResource = 'stak'; // definition of our resource for defining stack size
-
-
- // _________________________________________________________________________________________________________ //
- // TMemory Class Interface.
- class TMemory
- // TMemory is a simple memory utility class that keeps track of size of the stack and heap, and could
- // be used to manipulate the memory sizes.
- {
- public:
- // TYPEDEFS AND ENUMS
- enum EConstants // constants used in the TMemory class
- {
- kNoMinHeap = 0, kNoMinStack = 0
- };
-
- // CONSTRUCTORS AND DESTRUCTORS
- TMemory(const long minHeap = kNoMinHeap,
- // default constructor
- // default constructor
- const long minStack = kNoMinStack);
- virtual~ TMemory(); // default destructor
-
- // MAIN INTERFACE
- virtual long GetStackSize(); // get size of stack
- virtual Boolean SetStackSize(const long stackValue);// set new stack size
- virtual Boolean SetStackSizeFromResources();// set stack sizes based on resource information
- virtual Boolean IncreaseStackSize(const long stackValue);// increase the current stack size
- virtual Boolean CheckStackSize(); // check if selected min stack size is OK
- virtual Boolean CheckHeapSize(); // check if selected min heap size is OK
-
- virtual long GetHeapSize(); // get size of heap
-
- // FIELDS
- protected:
- long fMinHeap; // minimum heap size
- long fMinStack; // minimum stack size
- OSErr fError; // latest error
-
- // PRIVATE STRUCTURES
- private:
- struct StackResource // for the kStackResource resource mapping
- {
- long stackVal; // the new stack size
- };
-
-
- typedef StackResource* StackValuePtr; // typecasted for handy re-use
- typedef StackResource** StackValueHandle;
- };
-
-
- #endif
-
- // _________________________________________________________________________________________________________ //
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 1/2/93 New file
- 2 khs 1/3/93 Cleanup
- */
-